﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RRRSRoguelike.Managers;
using RRRSRoguelike.Helpers;
using System.Drawing;

namespace RRRSRoguelike.Screens
{
    class QuitScreen:Screen
    {
        Panel MainPanel;

        public QuitScreen()
        {
            Panels.Add(new Panel(new Point(4, 3),
                  DungeonVisualizer.GetScreenWidth() - 9, DungeonVisualizer.GetScreenHeight() - 6)); 

            MainPanel =  Panels[0];
        }

        public override void Show()
        {
            Clear();

            MainPanel.Draw();

            MainPanel.Write("Are you sure you wish to quit (y or n) ?",ConsoleColor.White,TextAlignment.Multi);
           
            ConsoleKey quit = Console.ReadKey(true).Key;
            if (quit.Equals(ConsoleKey.Y))
            {
                //Testing if this is needed
                //DungeonManager.Instance.gameOver = true;

                if (GameManager.Instance.DungeonScreen.replayScreen.ShowYesNo())
                { 
                    //Do nothing and fall through
                }
                else
                {
                    //MainPanel.Draw();
                    //MainPanel.Write("See you later!");
                    //WaitKey();
                    //GameManager.Instance.Exit();
                    DungeonManager.Instance.Initialize();
                    MenuScreen ms = new MenuScreen();
                    ms.Show();
                }
            }
            else
            {
                MainPanel.Clear();
                MainPanel.Write("Keep playing");

                DungeonManager.Instance.ForceRedraw();
            }
            DungeonManager.Instance.PlaySound(SoundList.Pluck);
        }
    }
}
